﻿using Autofac;
using Autofac.Integration.Mvc;
using Autofac.Extras.DynamicProxy;
using Knife.Core.Aspect;
using Knife.Core.DataBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Knife.Core.Util
{
    public class StartUpUtil
    {
        public static void StartLoadSystem()
        {
            EntityMapper.GetInstance().ScanStruct();
            var builder = new ContainerBuilder();
            builder.RegisterType<GlobalTransitionAspect>();
            var assemblies = System.Web.Compilation.BuildManager.GetReferencedAssemblies().Cast<Assembly>().ToArray();
            builder.RegisterControllers(assemblies).EnableClassInterceptors();
            var container = builder.Build();
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
    }
}
